package com.xique.park.controller.client;


import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.web.page.TableDataInfo;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.client.ParkClientUserInfo;
import com.xique.park.service.service.IParkClientUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗亭用户中间Controller
 *
 * @author caogq
 * @date 2021-07-20
 */
@Controller
@RequestMapping("/oms/parkClientUserInfo")
public class ParkClientUserInfoController extends BaseController {
    private String prefix = "oms/parkClientUserInfo";

    @Autowired
    private IParkClientUserInfoService parkClientUserInfoService;

    @PreAuthorize(hasPermi = "oms:parkClientUserInfo:view")
    @GetMapping()
    public String parkClientUserInfo() {
        return prefix + "/parkClientUserInfo";
    }

    /**
     * 查询岗亭用户中间列表
     */
    @PreAuthorize(hasPermi = "oms:parkClientUserInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ParkClientUserInfo parkClientUserInfo) {
        startPage();
        List<ParkClientUserInfo> list = parkClientUserInfoService.selectParkClientUserInfoList(parkClientUserInfo);
        return getDataTable(list);
    }


    /**
     * 新增岗亭用户中间
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存岗亭用户中间
     */
    @PreAuthorize(hasPermi = "oms:parkClientUserInfo:add")
    @Log(title = "岗亭用户中间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ParkClientUserInfo parkClientUserInfo) {
        return toAjax(parkClientUserInfoService.insertParkClientUserInfo(parkClientUserInfo));
    }

    /**
     * 修改岗亭用户中间
     */
    @GetMapping("/edit/{clientId}")
    public String edit(@PathVariable("clientId") Long clientId, ModelMap mmap) {
        ParkClientUserInfo parkClientUserInfo = parkClientUserInfoService.selectParkClientUserInfoById(clientId);
        mmap.put("parkClientUserInfo", parkClientUserInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存岗亭用户中间
     */
    @PreAuthorize(hasPermi = "oms:parkClientUserInfo:edit")
    @Log(title = "岗亭用户中间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ParkClientUserInfo parkClientUserInfo) {
        return toAjax(parkClientUserInfoService.updateParkClientUserInfo(parkClientUserInfo));
    }

    /**
     * 删除岗亭用户中间
     */
    @PreAuthorize(hasPermi = "oms:parkClientUserInfo:remove")
    @Log(title = "岗亭用户中间", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
//        return toAjax(parkClientUserInfoService.deleteParkClientUserInfoByIds(ids));
        return AjaxResult.success();
    }
}
